package logic

import (
	"com.wen/dal/db"
	"com.wen/model"
	"fmt"
)

func GetCommentList(articleId int64) (commentList []*model.Comment, err error) {
	//1. 首先，要验证article_id是否合法
	exist, err := db.IsArticleExist(articleId)
	if err != nil {
		fmt.Printf("query database failed, err:%v\n", err)
		return
	}

	if exist == false {
		err = fmt.Errorf("article id:%d not found", articleId)
		return
	}
	//2. 调用dal GetCommentList获取评论列表
	commentList, err = db.GetCommentList(articleId, 0, 100)
	return
}
